home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 1 / Cream of the Crop 1.iso / PROGRAM / MSC2BC.ARJ / FARHEAP.TXT < prev    next >
Text File  |  1992-06-26  |  3KB  |  49 lines

  1.           The following notes,  keyed  to comments in each program, explain
  2.           the differences:
  3.  
  4.           Note 1 - You can make short work out of converting  programs that
  5.           use Microsoft  C  far  heap  management  by  #defining functions,
  6.           structures, and variables that are the same or similar in Borland
  7.           C++.
  8.  
  9.           Note 2 - You need to  add  an array to maintain information about
  10.           the current size of each heap block.
  11.  
  12.           Note 3  -  You  need  to calculate and save the size of each heap
  13.           block before it is allocated with Borland C++.
  14.  
  15.           Note  4 - Borland C++ does not allow you to allocate a heap block
  16.           that is zero  bytes  in  size.  If  there is any chance that your
  17.           program can calculate a required heap block size  of  zero bytes,
  18.           you should check for that  possibility  prior  to  allocating the
  19.           block.
  20.  
  21.           Note  5 - Borland C++ far heap management  is  more  robust  than
  22.           Microsoft's, because it concatenates  adjacent  free  heap blocks
  23.           together to form a  single  larger heap block, and it reuses heap
  24.           blocks that were freed earlier.
  25.  
  26.           Note  6  -  The  Borland  C++ farheapinfo structure  is  slightly
  27.           different than the  Microsoft  C _heapinfo structure. The size of
  28.           the heap  block reported back by Microsoft _fheapwalk function is
  29.           exactly the amount requested by  your  program.  The  Borland C++
  30.           farheapwalk function reports the  size  of  the  entire structure
  31.           managed by the memory manager. This includes the amount of memory
  32.           accessible to your program, the  control  structure  used  by the
  33.           memory manager itself, and any  bytes necessary to pad the entire
  34.           heap structure to an exact multiple of 16 bytes.
  35.  
  36.           Note 7 -  The  Microsoft  C  _fheapwalk  function  allows  you to
  37.           examine  and  change  free  heap  blocks, memory which  does  not
  38.           legitimately belong to your program. The Borland  C++ farheapwalk
  39.           function  hides  free  heap blocks from you. With Borland C++, to
  40.           check  that the free far heap block is  not  corrupted,  use  the
  41.           farheapcheckfree function.
  42.  
  43.           Note 8 - In providing you with information about the state of the
  44.           heap, Microsoft C  defines  three  manifest  constants  for error
  45.           conditions which are not  defined  by  Borland  C++. Each of them
  46.           indicates a different type of corruption of the  heap,  and other
  47.           than reporting this fact, there is little else that you can do in
  48.           your program.
  49.